home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 3 / CD ACTUAL 3.iso / linux / incoming / jstools-.6v3 / jstools- / jstools-tk3.6v3.0 / lib / samples / jeditrc.tcl < prev    next >
Encoding:
Text File  |  1995-03-14  |  4.5 KB  |  152 lines

  1. # ~/.tk/jeditrc.tcl - user customisation file for jedit
  2. ######################################################################
  3.  
  4. ######################################################################
  5. # more procedures:
  6.  
  7. # deletesig t - delete the signature if it exists (and is tagged so):
  8.  
  9. proc deletesig { t } {
  10.   catch {
  11.     $t delete sig.first end
  12.   }
  13. }
  14.  
  15. ######################################################################
  16. # additions to GUI:
  17.  
  18. proc jedit:userhook { window } {
  19.   set t [jedit:top_to_text $window]    ;# relevant text widget
  20.   ######################################################################
  21.   # window icon:
  22.   
  23.   if {[winfo class $window] == "Toplevel"} {
  24.     catch {
  25.       global jed_icons
  26.       
  27.       if ![info exists jed_icons] {
  28.         set jed_icons 0
  29.       } else {
  30.         incr jed_icons
  31.       }
  32.       
  33.       wm withdraw $window
  34.       
  35.       set icon [j:new_toplevel .icon]
  36.       j:tk3 {$icon configure -geometry 48x48}
  37.       j:tk4 {$icon configure -width 48 -height 48}
  38.       wm withdraw $icon
  39.       frame $icon.menu -borderwidth 1 -width 48 -height 6 -relief raised
  40.       frame $icon.label -borderwidth 0 -width 48 -height 4 -relief flat
  41.       text $icon.text \
  42.         -background white -borderwidth 0 -relief flat -wrap none
  43.       catch {$icon.text configure -font nil2}
  44.       scrollbar $icon.sb -borderwidth 1 -width 6
  45.       pack $icon.menu
  46.       pack $icon.label
  47.       pack [j:rule $icon -relief flat -bg bisque3 -height 1] -fill x
  48.       pack $icon.sb -side right -fill y
  49.       pack $icon.text -side left -fill both -expand y
  50.       
  51.       update idletasks
  52.       
  53.       wm iconwindow $window $icon
  54.       wm geometry $icon 48x48
  55.       
  56.       # main window geometry (but this is really the window manager's job!)
  57.       #
  58.       set numjedits 0
  59.       foreach interp [winfo interps] {
  60.         if [string match {jedit*} $interp] {incr numjedits}
  61.       }
  62.       
  63.       set xoffset [expr {50 + ( $numjedits * 60 ) + ( $jed_icons * 50 ) }]
  64.       set yoffset [expr {25 + ( $numjedits * 35 ) + ( $jed_icons * 25 ) }]
  65.       
  66.       wm geometry $window +$xoffset+$yoffset
  67.       
  68.       foreach w [list $icon $icon.menu $icon.label $icon.text $icon.sb] {
  69.         foreach button {1 2 3 4 5} {
  70.           bind $w <Any-ButtonPress-$button> { }
  71.           bind $w <Any-ButtonPress-$button> "wm deiconify $window"
  72.         }
  73.       }
  74.     }
  75.     update
  76.     
  77.     bind $t <Unmap> [format {
  78.       %s.text delete 1.0 end
  79.       %s.text insert end [%s get 1.0 40.0]
  80.     } $icon $icon $t]
  81.     
  82.     bind $t <Destroy> "destroy $icon"
  83.     
  84.     wm deiconify $window
  85.   }
  86. }
  87.  
  88. proc jedit:mkmenu:user {menu t} {
  89.   $t tag configure hilight -background gold
  90.   $t tag raise hilight                ;# ????
  91.   
  92.   menubutton $menu -text {User} -menu $menu.m
  93.   
  94.   menu $menu.m
  95.   $menu.m add command -label {Hilight} -command "
  96.     $t tag add hilight sel.first sel.last
  97.   "
  98.   $menu.m add command -label {Unhilight} -command "
  99.     $t tag remove hilight sel.first sel.last
  100.   "
  101.   $menu.m add command -label {Clear All Hilights} -command "
  102.     $t tag remove hilight 1.0 end
  103.   "
  104.   $menu.m add separator
  105.   $menu.m add command -label {Gold on Red} -command "
  106.     jedit:format:background $t red
  107.     jedit:format:foreground $t gold
  108.     $t tag remove sel 1.0 end
  109.     jedit:format:background:clear $t
  110.     jedit:format:foreground:clear $t
  111.   "
  112.   $menu.m add command -label {Plain Colours} -command "
  113.     jedit:format:background:clear $t
  114.     jedit:format:foreground:clear $t
  115.   "
  116.   $menu.m add separator
  117.   $menu.m add command -label {Source . . .} -command {
  118.     source [j:fs {} {File to source:}]
  119.   }
  120.   $menu.m add command -label "C\346sar Cipher" -command [format {
  121.     jedit:pipe %s "tr \
  122.       abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ \
  123.       nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"
  124.   } $t]
  125.   $menu.m add command -label "Unquote" -command [format {
  126.     jedit:pipe %s "sed {s/^>//}"
  127.   } $t]
  128.   $menu.m add command -label {Insert Date} -command [format {
  129.     %s insert insert \
  130.     [exec date | awk "\{print \$2\" \"\$3\", \"\$6\}"]
  131.   } $t]
  132.   $menu.m add command -label {Insert Colour Name} -command [format {
  133.     %s insert insert \
  134.     [j:prompt_colour_name]
  135.   } $t]
  136.   $menu.m add command -label {Insert Colour RGB} -command [format {
  137.     %s insert insert \
  138.     [j:prompt_colour_rgb]
  139.   } $t]
  140.   $menu.m add command -label {Insert Font Name} -command [format {
  141.     %s insert insert \
  142.     [j:prompt_font]
  143.   } $t]
  144.   $menu.m add separator
  145.   $menu.m add command -label {New xterm} -command {
  146.     exec xterm &
  147.   }
  148.   $menu.m add command -label {New jbrowser} -command {
  149.     exec jbrowser &
  150.   }
  151. }
  152.